﻿CREATE PROCEDURE [dbo].[proc_Orders_GetItem]
	(
		@OId uniqueidentifier
	)
AS
Select
	Id,
	OId,
	OrderId,
	CustomerId,
	(Select CustomerName From Customer Where CustomerId=Orders.CustomerId) As CustomerName,
	ContactPerson,
	ContactPhone,
	UserName,
	IsNull((Select EName From Employee Where UserName=Orders.UserName),'...') As EName,
	IsNull((Select MobilePhone From Employee Where UserName=Orders.UserName),'...') As Tel,
	FixtureDate,
	Description,
	isnull(Aggregateamount,0) as Aggregateamount,
	isnull(Proceeds,0) as Proceeds,
	CreateDate,
	isnull(CompanyId,'0') As CompanyId,
	isnull(DepartmentId,'0') As DepartmentId,
	FinanceFlag,
	PaymentTypeId,
	(Select OpenBank From Finance_Bank Where Id=Orders.PaymentTypeId) As PaymentType,
	isnull(BaiDuAccount,'...') as BaiDuAccount,
	(select p.title from product p where p.id=MainProjectId) as MainProject,
	MainProjectId,
	IsNull((select p.cid from product p where p.id=MainProjectId),0) as IndustryId,
	IsReason,
	IsNull((Select EName From Employee Where UserName=Orders.TrackKf),'...') As TrackKf,
	isnull(TrackKfDepartmentId,0) as TrackKfDepartmentId
	From Orders Where OId=@OId
	RETURN
